#include <iostream>
#include <vector>
using namespace std;

//99.55%
class Solution
{
  public:
	void moveZeroes(vector<int> &nums)
	{
		int k = 0, len = nums.size();
		for (int i = 0; i < len; i++)
		{
			if (nums[i])
			{
				if (i != k)
				{
					nums[k] = nums[i];
					nums[i] = 0;
				}
				k++;
			}
		}
	}
};

int main()
{
	int nums[5] = {0, 1, 0, 3, 12};
	int len = sizeof(nums) / sizeof(int);
	vector<int> myVector(nums, nums + len);
	Solution().moveZeroes(myVector);
	for (int i = 0; i < len - 1; i++)
	{
		cout << myVector[i] << " ";
	}
	cout << myVector[len - 1] << endl;
	return 0;
}
